package com.spdd.mt.biz.constant;

import com.spdd.mt.common.base.BaseEnum;

/**
 * 订单状态枚举
 */
public enum OrderStatus implements BaseEnum<Integer> {
    SUCCESS(0, "成功"),
    FAILED(1, "失败"),
    PROCESSING(2, "处理中"),
    REEXCHANGE(3, "返销"),
    // READY(4, "待处理");
    ;

    private final Integer value;

    private final String desc;

    OrderStatus(Integer value, String desc) {
        this.value = value;
        this.desc = desc;
    }


    @Override
    public Integer getValue() {
        return value;
    }

    @Override
    public String getDesc() {
        return desc;
    }

    public static boolean isFinal(Integer orderStatus) {
        if (SUCCESS.getValue().equals(orderStatus)
                || FAILED.getValue().equals(orderStatus)
                || REEXCHANGE.getValue().equals(orderStatus)) {
            return true;
        }
        return false;
    }

    public static OrderStatus findByValue(Integer value) {
        for (OrderStatus orderStatus : OrderStatus.values()) {
            if (orderStatus.getValue().equals(value)) {
                return orderStatus;
            }
        }
        return null;
    }
}
